package com.study.zzedu.ui.forgetpwd;


import android.content.Context;

import com.study.zzedu.base.BasePresenter;
import com.study.zzedu.http.OnResultListener;

public class ForgetPwdPresenter extends BasePresenter<ForgetContract.IView> {

    private ForgetPwdModel pwdModel;

    public ForgetPwdPresenter() {
        this.pwdModel = new ForgetPwdModel();
    }

    //发送手机验证码
    public void getPhoneCode(Context context) {
        pwdModel.reSendPhoneCode(context, new OnResultListener() {
            @Override
            public void onSuccess(String result) {
                getView().getData(result);
            }

            @Override
            public void onError(String error) {
                getView().showError(error);
            }
        });
    }

    //进行身份验证
    public void identify(Context context,String code,String codeKey) {
        pwdModel.identify(context, code,codeKey,new OnResultListener() {
            @Override
            public void onSuccess(String result) {
                getView().getIdentifyData("");
            }

            @Override
            public void onError(String error) {
                getView().showError(error);
            }
        });
    }

    //进行修改
    public void modify(Context context,String pwd) {
        pwdModel.modify(context, pwd,new OnResultListener() {
            @Override
            public void onSuccess(String result) {
                getView().getModifyData("");
            }

            @Override
            public void onError(String error) {
                getView().showError(error);
            }
        });
    }

    //获取图片验证码
    public void getImageCode(Context context) {

        pwdModel.getImageCode(context,new OnResultListener() {
            @Override
            public void onSuccess(String result) {
                getView().onCodeReturn(result);
            }

            @Override
            public void onError(String error) {
                getView().onImageCodeError(error);
            }
        });
    }

    //根据学号获取手机号
    public void getPhoneByUserCode(Context context,String userCode, String code,String codeKey) {

        pwdModel.getPhoneByUserCode(context,userCode,code,codeKey,new OnResultListener() {
            @Override
            public void onSuccess(String result) {
                getView().onGetPhoneByUserCode(result);
            }

            @Override
            public void onError(String error) {
                getView().showError(error);
            }
        });
    }
}
